﻿<span style='font-size:11px; color:#000000; background:#ffffff; '><pre>
<span style='color:#800000; font-weight:bold; '>protected</span> <span style='color:#800000; font-weight:bold; '>void</span> convertToPdfButton_Click<span style='color:#808030; '>(</span><span style='color:#800000; font-weight:bold; '>object</span> sender<span style='color:#808030; '>,</span> EventArgs e<span style='color:#808030; '>)</span>
<span style='color:#800080; '>{</span>
    <span style='color:#696969; '>// Create a HTML to PDF converter object with default settings</span>
    HtmlToPdfConverter htmlToPdfConverter <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> HtmlToPdfConverter<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

    <span style='color:#696969; '>// Set license key received after purchase to use the converter in licensed mode</span>
    <span style='color:#696969; '>// Leave it not set to use the converter in demo mode</span>
    htmlToPdfConverter<span style='color:#808030; '>.</span>LicenseKey <span style='color:#808030; '>=</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>4W9+bn19bn5ue2B+bn1/YH98YHd3d3c=</span><span style='color:#800000; '>"</span><span style='color:#800080; '>;</span>

    <span style='color:#696969; '>// Set an adddional delay in seconds to wait for JavaScript or AJAX calls after page load completed</span>
    <span style='color:#696969; '>// Set this property to 0 if you don't need to wait for such asynchcronous operations to finish</span>
    htmlToPdfConverter<span style='color:#808030; '>.</span>ConversionDelay <span style='color:#808030; '>=</span> <span style='color:#008c00; '>2</span><span style='color:#800080; '>;</span>

    Document pdfDocument <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#800080; '>;</span>
    <span style='color:#800000; font-weight:bold; '>try</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#800000; font-weight:bold; '>string</span> htmlWithLinksAndAttachMarkers <span style='color:#808030; '>=</span> htmlStringTextBox<span style='color:#808030; '>.</span>Text<span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>string</span> baseUrl <span style='color:#808030; '>=</span> baseUrlTextBox<span style='color:#808030; '>.</span>Text<span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Convert a HTML string with markers for file links and attachments to a PDF document object</span>
        pdfDocument <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>ConvertHtmlToPdfDocumentObject<span style='color:#808030; '>(</span>htmlWithLinksAndAttachMarkers<span style='color:#808030; '>,</span> baseUrl<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Make the HTML element with 'text_note' mapping ID a text note</span>
        HtmlElementMapping textNoteMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>text_note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>textNoteMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage textNotePage <span style='color:#808030; '>=</span> textNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF textNoteRectangle <span style='color:#808030; '>=</span> textNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement textNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed text note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            textNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Note<span style='color:#800080; '>;</span>
            textNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            textNotePage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Make the HTML element with 'text_note_opened' mapping ID an initially opened text note</span>
        HtmlElementMapping textNoteOpenedMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>text_note_opened</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>textNoteOpenedMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage textNoteOpenedPage <span style='color:#808030; '>=</span> textNoteOpenedMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF textNoteOpenedRectangle <span style='color:#808030; '>=</span> textNoteOpenedMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement textNoteOpenedElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>textNoteOpenedRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially opened text note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            textNoteOpenedElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Note<span style='color:#800080; '>;</span>
            textNoteOpenedElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
            textNoteOpenedPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>textNoteOpenedElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Make the HTML element with 'help_note' mapping ID a help note</span>
        HtmlElementMapping helpNoteMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>help_note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>helpNoteMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage helpNotePage <span style='color:#808030; '>=</span> helpNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF helpNoteRectangle <span style='color:#808030; '>=</span> helpNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement helpNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>helpNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed help note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            helpNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Help<span style='color:#800080; '>;</span>
            helpNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            helpNotePage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>helpNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Make the HTML element with 'help_note_opened' mapping ID an initially opened help note</span>
        HtmlElementMapping helpNoteOpenedMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>help_note_opened</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>helpNoteOpenedMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage helpNoteOpenedPage <span style='color:#808030; '>=</span> helpNoteOpenedMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF helpNoteOpenedRectangle <span style='color:#808030; '>=</span> helpNoteOpenedMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement helpNoteOpenedElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>helpNoteOpenedRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially opened help note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            helpNoteOpenedElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Help<span style='color:#800080; '>;</span>
            helpNoteOpenedElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
            helpNoteOpenedPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>helpNoteOpenedElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Make the HTML element with 'comment_note' mapping ID a comment note</span>
        HtmlElementMapping commentNoteMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>comment_note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>commentNoteMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage commentNotePage <span style='color:#808030; '>=</span> commentNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF commentNoteRectangle <span style='color:#808030; '>=</span> commentNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement commentNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>commentNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed comment note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            commentNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Comment<span style='color:#800080; '>;</span>
            commentNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            commentNotePage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>commentNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Make the HTML element with 'comment_note_opened' mapping ID an initially opened comment note</span>
        HtmlElementMapping commentNoteOpenedMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>comment_note_opened</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>commentNoteOpenedMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage commentNoteOpenedPage <span style='color:#808030; '>=</span> commentNoteOpenedMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF commentNoteOpenedRectangle <span style='color:#808030; '>=</span> commentNoteOpenedMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement commentNoteOpenedElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>commentNoteOpenedRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially opened comment note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            commentNoteOpenedElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Comment<span style='color:#800080; '>;</span>
            commentNoteOpenedElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>true</span><span style='color:#800080; '>;</span>
            commentNoteOpenedPage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>commentNoteOpenedElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Make the HTML element with 'paragraph_note' mapping ID a paragraph note</span>
        HtmlElementMapping paragraphNoteMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>paragraph_note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>paragraphNoteMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage paragraphNotePage <span style='color:#808030; '>=</span> paragraphNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF paragraphNoteRectangle <span style='color:#808030; '>=</span> paragraphNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement paragraphNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>paragraphNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed paragraph note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            paragraphNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Paragraph<span style='color:#800080; '>;</span>
            paragraphNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            paragraphNotePage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>paragraphNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Make the HTML element with 'new_paragraph_note' mapping ID a new paragraph note</span>
        HtmlElementMapping newParagraphNoteMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>new_paragraph_note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>newParagraphNoteMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage newParagraphNotePage <span style='color:#808030; '>=</span> newParagraphNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF newParagraphNoteRectangle <span style='color:#808030; '>=</span> newParagraphNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement newParagraphNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>newParagraphNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed new paragraph note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            newParagraphNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>NewParagraph<span style='color:#800080; '>;</span>
            newParagraphNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            newParagraphNotePage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>newParagraphNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Make the HTML element with 'key_note' mapping ID a key note</span>
        HtmlElementMapping keyNoteMapping <span style='color:#808030; '>=</span> htmlToPdfConverter<span style='color:#808030; '>.</span>HtmlElementsMappingOptions<span style='color:#808030; '>.</span>HtmlElementsMappingResult<span style='color:#808030; '>.</span>GetElementByMappingId<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>key_note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>keyNoteMapping <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
        <span style='color:#800080; '>{</span>
            PdfPage keyNotePage <span style='color:#808030; '>=</span> keyNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>PdfPage<span style='color:#800080; '>;</span>
            RectangleF keyNoteRectangle <span style='color:#808030; '>=</span> keyNoteMapping<span style='color:#808030; '>.</span>PdfRectangles<span style='color:#808030; '>[</span><span style='color:#008c00; '>0</span><span style='color:#808030; '>]</span><span style='color:#808030; '>.</span>Rectangle<span style='color:#800080; '>;</span>

            <span style='color:#696969; '>// Create the text note</span>
            TextNoteElement keyNoteElement <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>new</span> TextNoteElement<span style='color:#808030; '>(</span>keyNoteRectangle<span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>This is an initially closed key note</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
            keyNoteElement<span style='color:#808030; '>.</span>NoteIcon <span style='color:#808030; '>=</span> TextNoteIcon<span style='color:#808030; '>.</span>Key<span style='color:#800080; '>;</span>
            keyNoteElement<span style='color:#808030; '>.</span>Open <span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>false</span><span style='color:#800080; '>;</span>
            keyNotePage<span style='color:#808030; '>.</span>AddElement<span style='color:#808030; '>(</span>keyNoteElement<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
        <span style='color:#800080; '>}</span>

        <span style='color:#696969; '>// Save the PDF document in a memory buffer</span>
        <span style='color:#800000; font-weight:bold; '>byte</span><span style='color:#808030; '>[</span><span style='color:#808030; '>]</span> outPdfBuffer <span style='color:#808030; '>=</span> pdfDocument<span style='color:#808030; '>.</span>Save<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Send the PDF as response to browser</span>

        <span style='color:#696969; '>// Set response content type</span>
        Response<span style='color:#808030; '>.</span>AddHeader<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Content-Type</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> <span style='color:#800000; '>"</span><span style='color:#0000e6; '>application/pdf</span><span style='color:#800000; '>"</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Instruct the browser to open the PDF file as an attachment or inline</span>
        Response<span style='color:#808030; '>.</span>AddHeader<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>Content-Disposition</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> String<span style='color:#808030; '>.</span>Format<span style='color:#808030; '>(</span><span style='color:#800000; '>"</span><span style='color:#0000e6; '>attachment; filename=Text_Notes.pdf; size={0}</span><span style='color:#800000; '>"</span><span style='color:#808030; '>,</span> outPdfBuffer<span style='color:#808030; '>.</span>Length<span style='color:#808030; '>.</span>ToString<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// Write the PDF document buffer to HTTP response</span>
        Response<span style='color:#808030; '>.</span>BinaryWrite<span style='color:#808030; '>(</span>outPdfBuffer<span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>

        <span style='color:#696969; '>// End the HTTP response and stop the current page processing</span>
        Response<span style='color:#808030; '>.</span>End<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
    <span style='color:#800000; font-weight:bold; '>finally</span>
    <span style='color:#800080; '>{</span>
        <span style='color:#696969; '>// Close the PDF document</span>
        <span style='color:#800000; font-weight:bold; '>if</span> <span style='color:#808030; '>(</span>pdfDocument <span style='color:#808030; '>!</span><span style='color:#808030; '>=</span> <span style='color:#800000; font-weight:bold; '>null</span><span style='color:#808030; '>)</span>
            pdfDocument<span style='color:#808030; '>.</span>Close<span style='color:#808030; '>(</span><span style='color:#808030; '>)</span><span style='color:#800080; '>;</span>
    <span style='color:#800080; '>}</span>
<span style='color:#800080; '>}</span>
</pre>
</span>